﻿using System.Linq;
using System.Web.Mvc;
using KaytechSoftware.Cms.App.Areas.Content.Models;
using KaytechSoftware.Cms.Services.Interfaces.Entity;

namespace KaytechSoftware.Cms.App.Areas.Content.Controllers
{
    public class PhotoAlbumController : Controller
    {
        private readonly IPhotoService _photoService;

        public PhotoAlbumController(IPhotoService photoService)
        {
            _photoService = photoService;
        }

        public ViewResult Show(long id)
        {
            var photos = _photoService.GetAllFromAlbum(id);
            var model = new PhotoBundleModel();
            model.PhotoAlbumId = id;
            model.Photos = photos.Select(p => new PhotoModel {Id = p.Id, Version = p.Version}).ToList();
            return View(model);
        }
    }
}
